home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / chip-away.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2005-06-30  |  6.8 KB  |  194 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ;  Supposed to look vaguely like roughly carved wood. Chipped away if you will.
  5. ;
  6. ;  Options: Text String -  the string to make the logo from
  7. ;           Font        -  which font to use
  8. ;           Font Size   -  how big
  9. ;           Chip Amount - how rought he chipping is (how spread the bump map is)
  10. ;           Blur Amount - the bump layer is blurred slighty by this amount
  11. ;           Invert      - whether or not to invert the bumpmap (gives a carved in feel)
  12. ;           Drop Shadow - whether or not to draw a drop shadow
  13. ;           Keep bump layer? - whether to keep the layer used as the bump map
  14. ;           fill bg with pattern? - whether to fill the background with the pattern or leave it white
  15. ;           Keep Backgroun - whether or not to remove the background layer
  16. ;
  17. ;  Adrian Likins  (Adrian@gimp.org)
  18. ;  Jan 11, 1998 v1
  19. ;
  20. ;  see http://www.gimp.org/~adrian/script.html
  21. ;
  22. ; This program is free software; you can redistribute it and/or modify
  23. ; it under the terms of the GNU General Public License as published by
  24. ; the Free Software Foundation; either version 2 of the License, or
  25. ; (at your option) any later version.
  26. ;
  27. ; This program is distributed in the hope that it will be useful,
  28. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  30. ; GNU General Public License for more details.
  31. ;
  32. ; You should have received a copy of the GNU General Public License
  33. ; along with this program; if not, write to the Free Software
  34. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  35. ;
  36. ;  Some suggested patterns: Dried mud, 3D green, Slate
  37. ;
  38.  
  39. (define (apply-chip-away-logo-effect img
  40.                      logo-layer
  41.                      spread-amount
  42.                      blur-amount
  43.                      invert
  44.                      drop-shadow
  45.                      keep-bump
  46.                      bg-fill
  47.                      keep-back
  48.                      pattern)
  49.   (let* ((width (car (gimp-drawable-width logo-layer)))
  50.      (height (car (gimp-drawable-height logo-layer)))
  51.      (bg-layer (car (gimp-layer-new img width height RGB-IMAGE "Background" 100 NORMAL-MODE)))
  52.      (bump-layer (car (gimp-layer-new img width height RGBA-IMAGE "Bump Layer" 100 NORMAL-MODE))))
  53.  
  54.     (gimp-context-push)
  55.  
  56.     (script-fu-util-image-resize-from-layer img logo-layer)
  57.     (gimp-image-add-layer img bg-layer 1)
  58.     (gimp-layer-set-preserve-trans logo-layer TRUE)
  59.     (gimp-context-set-pattern pattern)
  60.  
  61.     (gimp-context-set-background '(255 255 255))
  62.     (gimp-selection-all img)
  63.  
  64.     (if (= bg-fill TRUE)
  65.     (gimp-edit-bucket-fill bg-layer 2 NORMAL-MODE 100 255 FALSE 1 1)
  66.     (gimp-edit-fill bg-layer BACKGROUND-FILL))
  67.  
  68.     (gimp-image-add-layer img bump-layer 1)
  69.  
  70.     (gimp-selection-all img)
  71.     (gimp-edit-clear bump-layer)
  72.     (gimp-selection-none img)
  73.     (gimp-selection-layer-alpha logo-layer)
  74.     (gimp-edit-fill bump-layer BACKGROUND-FILL)
  75.     (gimp-edit-bucket-fill logo-layer 2 NORMAL-MODE 100 255 FALSE 1 1)
  76.     (gimp-selection-none img)
  77.  
  78.     (gimp-layer-set-preserve-trans bump-layer FALSE)
  79.     (plug-in-spread 1 img bump-layer spread-amount spread-amount)
  80.     (gimp-selection-layer-alpha bump-layer)
  81.     (plug-in-gauss-rle 1 img bump-layer blur-amount TRUE TRUE)
  82.  
  83.     (gimp-selection-none img)
  84.  
  85.     (plug-in-bump-map 1 img logo-layer bump-layer 135.00 25.0 60 0 0 0 0 TRUE invert 1)
  86.  
  87.     (gimp-drawable-set-visible bump-layer FALSE)
  88.  
  89.      (if (= drop-shadow TRUE)
  90.     (begin
  91.       (let* ((shadow-layer (car (gimp-layer-new img width height RGBA-IMAGE "Shadow layer" 100 NORMAL-MODE))))
  92.         (gimp-image-add-layer img shadow-layer 1)
  93.         (gimp-selection-all img)
  94.         (gimp-edit-clear shadow-layer)
  95.         (gimp-selection-none img)
  96.         (gimp-selection-layer-alpha logo-layer)
  97.         (gimp-context-set-background '(0 0 0))
  98.         (gimp-edit-fill shadow-layer BACKGROUND-FILL)
  99.         (gimp-selection-none img)
  100.         (plug-in-gauss-rle 1 img shadow-layer 5 TRUE TRUE)
  101.         (gimp-layer-translate shadow-layer 6 6))))
  102.  
  103.      (if (= keep-bump FALSE)
  104.      (gimp-image-remove-layer img bump-layer))
  105.  
  106.      (if (= keep-back FALSE)
  107.      (gimp-image-remove-layer img bg-layer))
  108.  
  109.     (gimp-context-pop)))
  110.  
  111. (define (script-fu-chip-away-logo-alpha img
  112.                     logo-layer
  113.                     spread-amount
  114.                     blur-amount
  115.                     invert
  116.                     drop-shadow
  117.                     keep-bump
  118.                     bg-fill
  119.                     keep-back
  120.                     pattern)
  121.   (begin
  122.     (gimp-image-undo-group-start img)
  123.     (apply-chip-away-logo-effect img logo-layer spread-amount blur-amount
  124.                  invert drop-shadow keep-bump bg-fill
  125.                  keep-back pattern)
  126.     (gimp-image-undo-group-end img)
  127.     (gimp-displays-flush)))
  128.  
  129. (script-fu-register "script-fu-chip-away-logo-alpha"
  130.             _"Chip Awa_y..."
  131.             "Chip away effect"
  132.             "Adrian Likins <adrian@gimp.org>"
  133.             "Adrian Likins <adrian@gimp.org>"
  134.             "1997"
  135.             "RGBA"
  136.                     SF-IMAGE      "Image"                 0
  137.                     SF-DRAWABLE   "Drawable"              0
  138.             SF-ADJUSTMENT _"Chip amount"          '(30 0 250 1 10 0 1)
  139.             SF-ADJUSTMENT _"Blur amount"          '(3 1 100 1 10 1 0)
  140.             SF-TOGGLE     _"Invert"               FALSE
  141.             SF-TOGGLE     _"Drop shadow"          TRUE
  142.             SF-TOGGLE     _"Keep bump layer"      FALSE
  143.             SF-TOGGLE     _"Fill BG with pattern" TRUE
  144.             SF-TOGGLE     _"Keep background"      TRUE
  145.             SF-PATTERN    _"Pattern"              "Burlwood")
  146.  
  147. (script-fu-menu-register "script-fu-chip-away-logo-alpha"
  148.              _"<Image>/Script-Fu/Alpha to Logo")
  149.  
  150.  
  151. (define (script-fu-chip-away-logo text
  152.                   font
  153.                   font-size
  154.                   spread-amount
  155.                   blur-amount
  156.                   invert
  157.                   drop-shadow
  158.                   keep-bump
  159.                   bg-fill
  160.                   keep-back
  161.                   pattern)
  162.   (let* ((img (car (gimp-image-new 256 256 RGB)))
  163.      (text-layer (car (gimp-text-fontname img -1 0 0
  164.                      text 30 TRUE font-size PIXELS font))))
  165.     (gimp-image-undo-disable img)
  166.     (gimp-drawable-set-name text-layer text)
  167.     (apply-chip-away-logo-effect img text-layer spread-amount blur-amount
  168.                  invert drop-shadow keep-bump bg-fill
  169.                  keep-back pattern)
  170.     (gimp-image-undo-enable img)
  171.     (gimp-display-new img)))
  172.  
  173. (script-fu-register "script-fu-chip-away-logo"
  174.             _"Chip Awa_y..."
  175.             "Chip away effect"
  176.             "Adrian Likins <adrian@gimp.org>"
  177.             "Adrian Likins <adrian@gimp.org>"
  178.             "1997"
  179.             ""
  180.             SF-STRING     _"Text"                 "Sloth"
  181.             SF-FONT       _"Font"                 "RoostHeavy"
  182.             SF-ADJUSTMENT _"Font size (pixels)"   '(200 2 1000 1 10 0 1)
  183.             SF-ADJUSTMENT _"Chip amount"          '(30 0 250 1 10 0 1)
  184.             SF-ADJUSTMENT _"Blur amount"          '(3 1 100 1 10 1 0)
  185.             SF-TOGGLE     _"Invert"               FALSE
  186.             SF-TOGGLE     _"Drop shadow"          TRUE
  187.             SF-TOGGLE     _"Keep bump layer"      FALSE
  188.             SF-TOGGLE     _"Fill BG with pattern" TRUE
  189.             SF-TOGGLE     _"Keep background"      TRUE
  190.             SF-PATTERN    _"Pattern"              "Burlwood")
  191.  
  192. (script-fu-menu-register "script-fu-chip-away-logo"
  193.              _"<Toolbox>/Xtns/Script-Fu/Logos")
  194.